#include "Transform.h"


__ImplementClass(Transform, std::string("Transform"), Component);


Transform::Transform()
{   
	/*
	SceneManager* pSceneManager = Root::getSingletonPtr()->getSceneManager("DummyScene");
	if (pSceneManager)
	{
		m_pSceneNode = pSceneManager->getRootSceneNode()->createChildSceneNode();
	}
	*/
    
}

Transform::~Transform()
{

}

void Transform::Update(float delta)
{

}

void Transform::Attach(void* pAttachObject,TransformType type)
{   

    mType = type;
	m_pAttachObject = pAttachObject;
	switch(type)
	{
	case TRANSFORM_SCENE_NODE:
		{
			//float fScale = 200;
			//((SceneNode*)m_pAttachObject)->setScale(fScale,fScale,fScale);
		}
		break;
	case TRANSFORM_CAMERA:
		break;
	}
	

}

void Transform::setPosition(Vector3 *pos)
{
   
   switch(mType)
   {
   case TRANSFORM_SCENE_NODE:
	   ((SceneNode*)m_pAttachObject)->setPosition(*pos);
	   break;
   case TRANSFORM_CAMERA:
	    ((Camera*)m_pAttachObject)->setPosition(*pos);
	   break;
   }

}

void Transform::getPosition(Vector3 *pos)
{   
	
	switch(mType)
	{
	case TRANSFORM_SCENE_NODE:
		{
			const Vector3 &position = ((SceneNode*)m_pAttachObject)->getPosition();
			*pos = position;
		}
		break;
	case TRANSFORM_CAMERA:
		{
			const Vector3 &position = ((Camera*)m_pAttachObject)->getPosition();
			*pos = position;
		}
		break;
	}

}

void Transform::setRotation(Quaternion *q)
{
   
   switch(mType)
   {
   case TRANSFORM_SCENE_NODE:
	   {
		   ((SceneNode*)m_pAttachObject)->setOrientation(*q);
	   }
	   break;
   case TRANSFORM_CAMERA:
	   {
           ((Camera*)m_pAttachObject)->setOrientation(*q);
	   }
	   break;
   }

}

void Transform::getRotation(Quaternion *q)
{
  
   switch(mType)
   {
   case TRANSFORM_SCENE_NODE:
	   {
		   const Quaternion &qt = ((SceneNode*)m_pAttachObject)->getOrientation();
		   *q = qt;
	   }
	   break;
   case TRANSFORM_CAMERA:
	   {
		   const Quaternion &qt = ((Camera*)m_pAttachObject)->getOrientation();
		   *q = qt;
	   }
	   break;
   }
}

void Transform::setRotation(Vector3 *axis,Radian &angle)
{
  
   switch(mType)
   {
   case TRANSFORM_SCENE_NODE:
	   {
		   Ogre::Quaternion Qt(angle,*axis);
		   ((SceneNode*)m_pAttachObject)->setOrientation(Qt);
		 
	   }
	   break;
   case TRANSFORM_CAMERA:
	   {

	   }
	   break;
   }

}

void Transform::setScale(Vector3 *scale)
{
  
   switch(mType)
   {
   case TRANSFORM_SCENE_NODE:
	   {
		   ((SceneNode*)m_pAttachObject)->setScale(*scale);

	   }
	   break;
   case TRANSFORM_CAMERA:
	   {

	   }
	   break;
   }

}